import instance from '@/http/index.js'

// 登录
export const register = data => {
  const { account, password } = data
  return instance({
    // 返回后端Server/router/login.js  router.post('/register', expressJoi(login_limit), loginHandler.register)
    // `/api`是因为在后端app.js中，app.use('/api', loginRouter)
    url: '/api/register',
    method: 'POST',
    data: {
      account,
      password
    }
  })
}

// 注册
export const login = data => {
  const { account, password } = data
  return instance({
    url: '/api/login',
    method: 'POST',
    data: {
      account,
      password
    }
  })
}

// 忘记密码,验证邮箱和账号是否对应
export const verify = data => {
  const { account,email } = data
  return instance({
    url: '/user/verifyAccountAndEmail',
		method: 'POST',
		data: {
			account,
			email
		}
  })
}

// 密码重置
export const reset = (id,newPassword) => {
  return instance({
    url:'/user/changePasswordInLogin',
    method: 'POST',
    data: {
      id,
      newPassword
    }
  })
}

// 返回路由列表
export const returnMenuList = (id) => {
  return instance({
    url:'/api/returnMenuList',
    method: 'POST',
    data: {
      id, 
    }
  })
}